package com.socket.socketObjTest;

import java.io.*;
import java.net.Socket;

/**
 * PetClient--bdqnPractice
 *
 * @author: Jovi
 * @createTime: 2017-09-14 10:48
 **/
public class PetClient {

    public static void main(String[] args) throws IOException {

        Socket socket = new Socket("localhost", 8989);

        OutputStream os = socket.getOutputStream();

        ObjectOutputStream oos = new ObjectOutputStream(os);

        Pet pet = new Pet("dog", "black");

        oos.writeObject(pet);

        socket.shutdownOutput();

        InputStream is = socket.getInputStream();

        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        String repay;

        while ((repay = br.readLine()) != null) {
            System.out.println("我是宠物店主人，宠物店响应：" + repay);
        }

        br.close();
        is.close();
        oos.close();
        os.close();
        socket.close();


    }

}
